import { AclUser, AclUseRes, AllRoleRes, setRoleParmas } from "@/types/acl";
import http from "@/utils/request";


//获取用户管理列表
export const getAclUserAPI=(page:number,limit:number,username:string)=>{
    return http<any, AclUseRes>({
        url:`/admin/acl/user/${page}/${limit}/?username=${username}`,
    })
}

//添加用户角色
export const addAclUserAPI=(data:AclUser)=>{
    return http<any,any>({
        url:'/admin/acl/user/save',
        method:'post',
        data
    })
}

//编辑角色
export const updateUserAPI=(data:AclUser)=>{
    return http<any,any>({
        url:'/admin/acl/user/update',
        method:'put',
        data
    })
}

//删除角色
export const delUserAPI=(id:number)=>{
    return http({
        url:`/admin/acl/user/remove/${id}`,
        method:'delete'
    })
}

//删除所有
export const delAllUserAPI=(idList:number[])=>{
    return http<any,any>({
        url:`/admin/acl/user/batchRemove`,
        method:'delete',
        data:idList
    })
}

//获取全部职位
export const getRoleAPI=(userId:number)=>{
    return http<any,AllRoleRes>({
        url:`/admin/acl/user/toAssign/${userId}`
    })
}

//分配角色
export const setRoleAPI=(data:setRoleParmas)=>{
    return http<any,any>({
        url:'/admin/acl/user/doAssignRole',
        method:'POST',
        data
    })
}

//获取角色信息
export const getRoleDetail=(page:number,limit:number,roleName:string)=>{
    return http({
        url:`/admin/acl/role/${page}/${limit}/?roleName=${roleName}`
    })
}